package com.microservice.common.utils;

/**
 * 统一返回结果工具类
 */
public class ResultUtil {
    
    /**
     * 成功返回
     */
    public static <T> Result<T> success(T data) {
        return new Result<>(200, "success", data);
    }
    
    /**
     * 失败返回
     */
    public static <T> Result<T> error(String message) {
        return new Result<>(500, message, null);
    }
    
    /**
     * 返回结果类
     */
    public static class Result<T> {
        private int code;
        private String message;
        private T data;
        
        public Result(int code, String message, T data) {
            this.code = code;
            this.message = message;
            this.data = data;
        }
        
        public int getCode() {
            return code;
        }
        
        public void setCode(int code) {
            this.code = code;
        }
        
        public String getMessage() {
            return message;
        }
        
        public void setMessage(String message) {
            this.message = message;
        }
        
        public T getData() {
            return data;
        }
        
        public void setData(T data) {
            this.data = data;
        }
    }
}
